﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Task07_GraphGenerator
{
	class Program
	{
		static void Main(string[] args)
		{
			const int GraphNodes = 1000;
			int[,] graph = new int[GraphNodes, GraphNodes];
			Random rnd = new Random();

			for (int i = 0; i < GraphNodes; i++)
			{
				int vertexesCount = rnd.Next(1, GraphNodes / 50);
				for (int j = 0; j < vertexesCount; j++)
				{
					int newVertex = rnd.Next(1, GraphNodes);
					while (graph[i, newVertex] != 0)
					{
						newVertex = rnd.Next(1, GraphNodes);
					}

					graph[i, newVertex] = 1;
				}
			}

			StringBuilder graphMatrix = new StringBuilder();
			graphMatrix.AppendLine(GraphNodes.ToString());

			for (int i = 0; i < GraphNodes; i++)
			{
				for (int j = 0; j < GraphNodes; j++)
				{
					graphMatrix.AppendFormat("{0}, ", graph[i, j]);
				}
				graphMatrix.Remove(graphMatrix.Length - 2, 1);
				graphMatrix.AppendLine();
			}

			Console.WriteLine(graphMatrix.ToString());
		}
	}
}
